package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.OperationLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户操作日志 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-06-16
 */
@Mapper
public interface OperationLogMapper extends BaseMapper<OperationLog> {

    @Select("<script>" +
            "select a.*,b.username from dragon_operation_log a left join dragon_admin b on a.admin_id = b.id " +
            "where b.id IS NOT NULL" +
            "<if test='adminId!=null and adminId != \"\"'>" +
            " AND b.id = #{adminId}" +
            "</if>" +
            "<if test='username!=null and username != \"\"'>" +
            " AND b.username like CONCAT('%',#{username},'%')" +
            "</if>" +
            "</script>")
    Page<OperationLog> selectPageByUsernameOrAdminId(Page<OperationLog> page,Integer adminId,String username);
}
